/*
 * 文件名：CarInMemberResponceHandler.java	 
 * 时     间：下午8:57:03
 * 作     者：lyf       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.message.handler.impl;

import java.util.Map;

import org.springframework.context.ApplicationContext;

import com.cz073586.tools.util.JsonUtil;
import com.cz073586.tools.util.Log4jUtil;
import com.cz073586.tools.util.Tools;
import com.local.model.Integration;
import com.local.service.face.IntegrationService;
import com.message.entity.TransDataVo;
import com.message.handler.face.ResponceHandler;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.exception.BaseException;
import com.qianhai.common.utils.I18nUtil;

/**
 * 类描述: 处理车辆进场时返回其他平台会员信息.
 * 
 * @ClassName: CarInMemberResponceHandler
 * @author Administrator
 * @date 2015年10月12日 下午8:57:03
 */
public class CarInMemberResponceHandler implements ResponceHandler
{
	private Log4jUtil log = Log4jUtil
			.getLog4j(CarInMemberResponceHandler.class);
	
	@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
	@Override
	public TransDataVo resoponse(ApplicationContext srpingApp,
			TransDataVo transData)
	{
		TransDataVo result = new TransDataVo<Integration>();
		if (!Tools.isEmpty(transData.getData()))
		{
			
			try
			{
				String json = JsonUtil.getJsonString(transData.getData());
				Integration intertion = JsonUtil.fromJson(json, Integration.class);
				IntegrationService serverice = srpingApp
						.getBean(IntegrationService.class);
				serverice.addOrUpdateByCarNo(intertion);
				
				result.setResult(CommonContans.STRUTS_SUCCESS);
			} catch (BaseException e)
			{
				log.error(e.getMessage(), e);
				result.setResult(CommonContans.STRUTS_ERROR);
				result.setErrorCode(e.getMessage().length() > 32 ? CommonContans.COMMON_ERROR_CODE
						: e.getMessage());
				result.setErrorMsg(e.getMessage().length() > 32 ? I18nUtil
						.getErroryCodeInfo(CommonContans.COMMON_ERROR_CODE)
						: I18nUtil.getErroryCodeInfo(e.getMessage()));
			}
		}
		return result;
	}
	
}
